<script>
	const index = require('@/api/personal/index.js')
	export default {
		data() {
			return {
				// projectId:''
			}
		},
		onLoad(options) {
			console.log(66666)
			console.log(options,'1111222')
		},
		async onLaunch() {
	
			uni.removeStorageSync('tarbar_index')
			console.log('App Launch')
			await this.initData();
		},
		onShow: function() {
			console.log('App Show')
			// getApp().globalData.projectId,globalData.projectId
		},
		onHide: function() {
			console.log('App Hide')
			if (uni.getStorageSync("fenx")) {
				this.getPointsByZhuanFa()
			} 
		},
		methods: {
			// 数据初始化
			async getPointsByZhuanFa() {
				let datas = {
					app_id: this.$https.weixinAppId,
					project_id: getApp().globalData.projectId,
					open_id: uni.getStorageSync("openid"),
				};
				index.getPointsByZhuanFa(datas).then(result => {
					if (result.code == 1) {
						uni.removeStorage({
							key: 'fenx',
							success: function (res) {
							}
						});
					}
				})
			},
			// 数据初始化
			async initData() {
				// 获取页面设置配置
				const _this = this;
				// 获取学员资料
					let params = {
						app_id: this.$https.weixinAppId,
					}
					// let res = await venues.getProjectIdByAppId(params)
					index.getProjectIdByAppId(params).then(result => {
						// _this.globalData.projectId = result.data.result
						// getApp().globalData.projectId = result.data.result
						getApp().globalData.projectId = result.data.result
						getApp().globalData.sign = result.data.sign;
						let buy_success = result.data.template_ids.buy_success  //购买通知id
						let refund_success = result.data.template_ids.refund_success  //退款通知id
						let share_success = result.data.template_ids.share_success   //分享通知id
						let class_begin = result.data.template_ids.class_begin   //分享通知id
							uni.setStorageSync('buy_success_id',buy_success)
							uni.setStorageSync('refund_success_id',refund_success)
							uni.setStorageSync('share_success_id',share_success)
							uni.setStorageSync('class_begin_id',class_begin)
					// uni.setStorageSync('projectId',result.data.result)
					
					})
			},
			
			onShareAppMessage: function (res) {
				console.log(res,'123')
			  // let rushList = this.data.rushList;
			  // let cate_info = rushList && rushList[0].cate_info;
			  // var share_title = (cate_info && cate_info.name) || '分类列表';
			  var share_title = '分类列表';
			  var share_id = 1212;
			  var id = 9999;
			  var share_path = `page_points/page_points/points_mall?id=${id}&share_id=${share_id}`;
			
			  return {
			    title: share_title,
			    path: share_path,
			    success: function (res) {
			      // 转发成功
			    },
			    fail: function (res) {
			      // 转发失败
			    }
			  }
			}
		
		},
		globalData: {
			projectId: '',
			
		},
		
	}

</script>

<style lang="scss">
	/* 注意要写在第一行，同时给style标签加入lang="scss"属性 */
	@import "@/uni_modules/uview-ui/index.scss";
</style>
